import { RouteObject, useSearchParams } from "react-router-dom"

import MainPage from "@/pages/ForgetPassword/MainPage"

import type { FormType } from "@/pages/AccountPage/formFactory"
import { FormFactory } from "@/pages/AccountPage/formFactory"
import { useParams } from "react-router-dom"

// eslint-disable-next-line react-refresh/only-export-components
const FormWrapper = () => {
    const { type } = useParams() as { type: string }
    const [searchParams] = useSearchParams()
    return <FormFactory type={type?.toLowerCase() as FormType}></FormFactory>
}

export const forgetpasswordRoutes: RouteObject[] = [
    {
        index: true,
        element: <MainPage />,
    },
    {
        path: "verify/:type",
        element: <FormWrapper />,
    },
]
